<template>
  <div class="deleteBox">
    <div class="title">
      <span>删除</span>
      <i class="el-icon-close" @click="close"></i>
    </div>
    <main>
      <p>
        <i class="el-icon-warning"></i>确定删除此条反馈？
      </p>
      <div class="btns">
        <div class="cancel" @click="close">取消</div>
        <div class="sure" @click="sure">确定</div>
      </div>
    </main>
  </div>
</template>

<script>
import { deleteFeedback } from '../../../api/feedback'
export default {
  methods: {
    close () {
      this.$store.commit('feedback/set_deleteId', '')
      this.$store.commit('set_ifShowCover', false)
    },
    sure () {
      deleteFeedback(this.$store.state.feedback.deleteId).then(async res => {
        if (res.data.code === 200) {
          this.$message({
            type: 'success',
            message: res.data.message
          })
          await this.$store.dispatch('feedback/getTypeList')
          await this.$store.dispatch('feedback/getList')
        } else {
          this.$message({
            type: 'error',
            message: res.data.message
          })
        }
        this.close()
      })
    }
  }
}
</script>

<style lang="scss" scoped>
.deleteBox {
  width: 560px;
  height: 360px;
  position: absolute;
  background-color: #fff;
  border-radius: 5px;
  top: 116px;
  z-index: 999;
  left: 460px;

  .title {
    padding-left: 20px;
    padding-right: 20px;
    height: 72px;
    line-height: 72px;
    border-bottom: 1px solid #f2f2f2;
    span {
      color: #333;
      font-size: 18px;
    }
    i {
      float: right;
      margin-top: 27px;
      cursor: pointer;
      font-size: 18px;
    }
  }
  main {
    p {
      margin-top: 56px;
      height: 24px;
      line-height: 24px;
      text-align: center;
      color: #333333;
      font-size: 18px;
      i {
        color: #ffb415;
        font-size: 20px;
        vertical-align: middle;
        margin-right: 12px;
      }
    }
    .btns {
      position: relative;
      margin-top: 120px;
      div {
        position: absolute;
        width: 128px;
        height: 48px;
        cursor: pointer;
        line-height: 48px;
        text-align: center;
        border-radius: 24px;
        font-size: 18px;
      }
      .cancel {
        left: 140px;
        border: 2px solid #4868FF;
        color: #4868FF;
      }

      .sure {
        left: 292px;
        background-color: #4868FF;
        color: #fff;
      }
    }
  }
}
</style>
